#include <QtGlobal> // for qAsConst, QAddConst<>::Type, qPrintable
#include "defs.h"
-#include "cet.h" // for cet_utf8_to_ucs4
#include "src/core/datetime.h" // for DateTime
#include "src/core/logging.h" // for Warning
#include "src/core/xmltag.h" // for xml_tag, xml_attribute, xml_findfirst, xml_findnext
char*
entitize(const char* str, bool is_html)
{
- int ecount;
- int nsecount;
char* p;
char* tmp;
char* xstr;
- int bytes = 0;
- int value = 0;
entity_types* ep = stdentities;
- int elen = ecount = nsecount = 0;
+ int elen = 0;
+ int ecount = 0;
/* figure # of entity replacements and additional size. */
while (ep->text) {
ep++;
}
- /* figure the same for other than standard entities (i.e. anything
- * that isn't in the range U+0000 to U+007F */
-
-#if 0
- for (cp = str; *cp; cp++) {
- if (*cp & 0x80) {
- cet_utf8_to_ucs4(cp, &bytes, &value);
- cp += bytes-1;
- elen += sprintf(tmpsub, "&#x%x;", value) - bytes;
- nsecount++;
- }
- }
-#endif
-
/* enough space for the whole string plus entity replacements, if any */
tmp = (char*) xcalloc((strlen(str) + elen + 1), 1);
strcpy(tmp, str);
- /* no entity replacements */
- if (ecount == 0 && nsecount == 0) {
- return (tmp);
- }
-
if (ecount != 0) {
for (ep = stdentities; ep->text; ep++) {
p = tmp;
}
}
- if (nsecount != 0) {
- p = tmp;
- while (*p) {
- if (*p & 0x80) {
- cet_utf8_to_ucs4(p, &bytes, &value);
- if (p[bytes]) {
- xstr = xstrdup(p + bytes);
- } else {
- xstr = nullptr;
- }
- sprintf(p, "&#x%x;", value);
- p = p+strlen(p);
- if (xstr) {
- strcpy(p, xstr);
- xfree(xstr);
- }
- } else {
- p++;
- }
- }
- }
return (tmp);
}